package com.dolphin.serviceorder.controller;

import com.dolphin.common.dto.OrderInfo;
import com.dolphin.serviceorder.mapper.OrderInfoMapper;
import com.dolphin.serviceorder.service.OrderInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class TestController {

    @Autowired
    OrderInfoService orderInfoService;
    @GetMapping("/test")
    public String test() {
        return "service-order";
    }

    @Value("${server.port}")
    private String port;

    @Autowired
    OrderInfoMapper orderInfoMapper;

    /**
     * 测试派单逻辑
     * @param orderId
     * @return
     */
    @GetMapping("/test-real-time-order/{orderId}")
    public String testDispatcherOrder(@PathVariable("orderId") long orderId){

        log.info("server-order 端口：{}  并发测试：orderId:{}",port,orderId);
        log.info("并发测试："+orderId);
        OrderInfo orderInfo = orderInfoMapper.selectById(orderId);
        orderInfoService.dispatchRealTimeOrder(orderInfo);
        return "test-real-time-order  success";
    }

}
